#pragma once
#include <atlstr.h>

class CUFile
{
public:
	CUFile();
	~CUFile();
	BOOL	OpenForRead(LPCTSTR lpFileName);
	BOOL	OpenForWrite(LPCTSTR lpFileName, BOOL bAppend=FALSE);
	void	Close();
	BOOL	ReadString(CString& rString);
	BOOL	ReadAll(CString& rString);
	DWORD	WriteString(LPCWSTR szString);
	DWORD	Write(LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite);
	BOOL	Flush();
	BOOL	IsFileOpened() const;
	void	GetFilePath(LPTSTR szPath, int nMaxChar);
	DWORD	GetFileLength();

	static BOOL	CreateEmptyUnicodeFile(LPCTSTR lpFileName);

private:
	BOOL	Open(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwCreationDisposition);
	HANDLE	m_hFile;
	BOOL	m_bIsUnicode;
	TCHAR	m_szFilePath[MAX_PATH];
};

/*
CUFile file;
if(file.OpenForRead(lpSafeIPFilePath))
{
	CStringE line;
	BOOL bReadOK=file.ReadString(line);
	while(bReadOK)
	{
		line.Trim();
		if(_T("")!=line)
		{

		}
		bReadOK=file.ReadString(line);
	}
	file.Close();
}
*/
